package main

import (
	"fmt"
	"time"
)

func main() {
	quit := make(chan int)
	lockCh := make(chan int)

	go person1(lockCh)
	go person2(lockCh, quit)
	<-quit
}

func printer(str string) {
	for _, ch := range str {
		fmt.Printf("%c", ch)
		time.Sleep(time.Millisecond * 300)
	}
}

func person1(lockch chan<- int) {
	printer("hello")
	lockch<-10
}

func person2(lockCh <-chan int,quit chan<- int) {
	<-lockCh
	printer("world")
	quit <- 10
}
